﻿var Controller = function(){}

Controller.Button = null;
Controller.ButtonOpenText = "打开主菜单&gt;&gt;&gt;";
Controller.ButtonCloseText = "关闭主菜单&lt;&lt;&lt;";

Controller.Init = function(buttonID)
{
	Controller.Button = document.getElementById(buttonID);
	if(!Controller.Button) return;
	
	if(top.Controller && parent.Controller)
	{
		if(top.Controller != parent.Controller)
		{
			Controller.Button.onclick = Controller.Click;
			
			if(top.Controller.IsOpenPanel)
				Controller.Button.innerHTML = Controller.ButtonCloseText;
			else
				Controller.Button.innerHTML = Controller.ButtonOpenText;
		}
	}
}

Controller.OpenTopPanel = function()
{
	top.Controller.OpenPanel();
	Controller.Button.innerHTML = Controller.ButtonCloseText;
}

Controller.CloseTopPanel = function()
{
	top.Controller.ClosePanel();
	Controller.Button.innerHTML = Controller.ButtonOpenText;
}

Controller.Click = function()
{
	if(top.Controller.IsOpenPanel)
		Controller.CloseTopPanel();
	else
		Controller.OpenTopPanel();
}